package it.polimi.swKnights.SWIMv2.servlets;

import it.polimi.swKnights.SWIMv2.ejb.abilityManager.AbilityHandlerRemote;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class ShowUserHome
 */
public class ShowUserHome extends SwimServlet
{
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException
	{
		HttpSession session = request.getSession();
		String username = (String) session.getAttribute("userName");
		AbilityHandlerRemote abilityBean = this.lookUp(AbilityHandlerRemote.class);
		Map<String,String> userAbilities = this.getUserAbilities(username);
		Map<String, String>  abilitiesInSystemMap = abilityBean.getAbilities();//all abilities in the system
		
		request.setAttribute("abilitiesMap",userAbilities);
		request.setAttribute("abilitiesInSystemMap", abilitiesInSystemMap);
		request.getRequestDispatcher("WEB-INF/users/userHome.jsp").forward(
				request, response);
	}
	
	

}
